package com.ge.boot03web.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Locale;

/**
 * @BelongsProject: SpringBoot
 * @BelongsPackage: com.ge.boot03web.controller
 * @Author: gejingyu
 * @Date: 2024/1/31
 * @Description: 测试多语言返回
 */

@RestController
public class MultiMessageController {

    @Autowired
    MessageSource messageSource;

    @GetMapping("/message")
    public String test(HttpServletRequest request){
        // 获取请求中的区域信息
        Locale locale = request.getLocale();
        return messageSource.getMessage("login", null, locale);
    }

}
